package com.itheima.article.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.article.pojo.ApArticleConfig;
import com.itheima.article.mapper.ApArticleConfigMapper;
import com.itheima.article.service.ApArticleConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.wemedia.dto.DownOrUpDto;
import org.springframework.stereotype.Service;

import javax.validation.constraints.NotNull;

/**
 * @description <p>APP已发布文章配置 业务实现</p>
 *
 * @version 1.0
 * @package com.itheima.article.service.impl
 */
@Service
public class ApArticleConfigServiceImpl extends ServiceImpl<ApArticleConfigMapper, ApArticleConfig> implements ApArticleConfigService {

    /**
     * 同步文章 上下架
     *
     * @param upOrDown
     */
    @Override
    public void upOrDown(DownOrUpDto upOrDown) {
        Long articleId = upOrDown.getId();
        ApArticleConfig updatePojo = new ApArticleConfig();
        updatePojo.setId(articleId);
        if(upOrDown.getEnable()==1){
            // 上架
            updatePojo.setIsDown(0);// 上架
        }else{
            updatePojo.setIsDown(1);// true, 下架
        }
        updatePojo.setIsDown(upOrDown.getEnable()==1?0:1);
        updateById(updatePojo);
    }
}
